Change in openvpn[master]: get_dafault_gateway(): Make sure the get_default_gateway() function n...
A message that is not in the archive (sent off-list or not yet received): gerrit.1739527719000.I02afe6817433ca21aae76671c35151ec6a066933@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
to review the following change.
Change subject: get_dafault_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
......................................................................
get_dafault_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
---
M src/openvpn/options.c
M src/openvpn/route.c
2 files changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/1
src/openvpn/options.c +1 -1
@@ -5872,7 +5872,7 @@get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway (&rgi, remote_ipv4 !=IPV4_INVALID_ADDR ? remote_ipv4 :INADDR_ANY , &net_ctx);get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
Change subject: get_dafault_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
......................................................................
Patch Set 1: Code-Review-1
(2 comments)
Patchset:
PS1:
Typo in get_dafault... in the commit message, and please add a few words why this is needed ("commit ... added using the remote VPN host address to query the default gateway which fails when connecting using IPv6")
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/898/comment/4d8cea43_70bff5a2 :
PS1, Line 5876: get_default_gateway_ipv6(&rgi6, &remote_ipv6, &net_ctx);
this change is not needed. get_ip_addr() will return 0 on everything that is not a valid IPv4 address (or can resolve to one).
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 14 Feb 2025 10:20:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Make sure the get_default_gateway() function n...
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, mrbff, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: get_default_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
......................................................................
get_default_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
---
M src/openvpn/route.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/2
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Make sure the get_default_gateway() function n...
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, plaisthos.
mrbff has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
Change subject: get_default_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/898/comment/55b5d053_1d2e65aa :
PS1, Line 5876: get_default_gateway_ipv6(&rgi6, &remote_ipv6, &net_ctx);
Quoted 1 line
this change is not needed. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 14 Feb 2025 10:33:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Make sure the get_default_gateway() function n...
In reply to a message not in the archiveAttention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
Change subject: get_default_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 14 Feb 2025 12:56:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 get_default_gateway(): Make sure the get_default_gateway() function never receives IPV4_INVALID_ADDR as a destination.
In reply to a message not in the archiveFrom: Marco Baffo <[email protected]...>
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/898
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destina...
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, mrbff, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review+2 by cron2
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
......................................................................
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
When using --redirect-gateway (IPv4) while connected to an IPv6 remote, OpenVPN still attempts to determine the IPv4 default gateway, so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff) as the destination, leading to unintended behavior:
- the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped.
- this prevents proper restoration of the original route when needed.
To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR, we now pass INADDR_ANY (0x00000000) to get_default_gateway(), ensuring the function behaves correctly.
---
M src/openvpn/route.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/3
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destina...
In reply to a message not in the archiveAttention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
Change subject: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 14 Feb 2025 15:34:18 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v3 1/1 get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
In reply to a message not in the archiveFrom: Marco Baffo <[email protected]...>
When using --redirect-gateway (IPv4) while connected to an IPv6 remote, OpenVPN still attempts to determine the IPv4 default gateway, so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff) as the destination, leading to unintended behavior:
- the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped.
- this prevents proper restoration of the original route when needed.
To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR, we now pass INADDR_ANY (0x00000000) to get_default_gateway(), ensuring the function behaves correctly.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/898
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
[Openvpn-devel] [PATCH applied] Re: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
There has been quite a bit of discussion about this one-liner on #openvpn-devel - this is not a particularily pretty piece of code, nor easy to understand. It's intended as a "do not break existing setups" bandaid, while we spend more thoughts on making this work better, and also clarify for ourselves and the documentation what "default gateway" and "route ... net_gateway" really means :-) - and possibly drop "non def1" redirection, which will simplify more of this.
Thanks for looking into this :-)
Your patch has been applied to the master branch.
commit 75ba07d496da269b13fc368311f8a063b65d58e7
Author: Marco Baffo Date: Fri Feb 14 16:34:34 2025 +0100
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
Signed-off-by: Marco Baffo <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30895.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destina...
In reply to a message not in the archivecron2 has uploaded a new patch set (#4) to the change originally created by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
......................................................................
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
When using --redirect-gateway (IPv4) while connected to an IPv6 remote, OpenVPN still attempts to determine the IPv4 default gateway, so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff) as the destination, leading to unintended behavior:
- the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped.
- this prevents proper restoration of the original route when needed.
To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR, we now pass INADDR_ANY (0x00000000) to get_default_gateway(), ensuring the function behaves correctly.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30895.html
---
M src/openvpn/route.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/4
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [XS] Change in openvpn[master]: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destina...
In reply to a message not in the archivecron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/898?usp=email )
Change subject: get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
......................................................................
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
When using --redirect-gateway (IPv4) while connected to an IPv6 remote, OpenVPN still attempts to determine the IPv4 default gateway, so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff) as the destination, leading to unintended behavior:
- the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped.
- this prevents proper restoration of the original route when needed.
To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR, we now pass INADDR_ANY (0x00000000) to get_default_gateway(), ensuring the function behaves correctly.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30895.html
---
M src/openvpn/route.c
1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +1 -1
@@ -655,7 +655,7 @@ rl->spec.flags |=RTSA_DEFAULT_METRIC ; } -get_default_gateway (&rl->rgi, remote_host, ctx); +get_default_gateway (&rl->rgi, remote_host !=IPV4_INVALID_ADDR ? remote_host :INADDR_ANY , ctx);if (rl->rgi.flags &RGI_ADDR_DEFINED ) {setenv_route_addr (es,"net_gateway" , rl->rgi.gateway.addr,-1 );
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Gerrit-Change-Number: 898
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged